﻿using System;

namespace Service
{
    /// <summary>
    /// Person Service Implementation
    /// </summary>
    public class PersonService : Contracts.IPersonService
    {
        private Guid _instanceId;
        private Contracts.IPersonRepository _personRepository;

        /// <summary>
        /// Initializes a new instance of the PersonService class.
        /// </summary>
        /// <param name="personRepository"></param>
        public PersonService(Contracts.IPersonRepository personRepository)
        {
            _instanceId = Guid.NewGuid();
            _personRepository = personRepository;
        }

        #region IPersonService Members

        public Contracts.PersonResponse SavePersonRecord(Contracts.PersonRequest request)
        {
            return new Contracts.PersonResponse(_instanceId.ToString(), String.Format("Added Person - {0}", _personRepository.SavePerson(request.Person)));
        }

        public Contracts.PersonResponse DeletePersonRecord(Contracts.PersonRequest request)
        {
            return new Contracts.PersonResponse(_instanceId.ToString(), String.Format("Deleted Person - {0}", _personRepository.DeletePerson(request.Person)));
        }

        #endregion
    }
}
